
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0786
 * @Author : WangRuoyu 
 * @Date : 2023/9/14 14:56
 */

#include "iostream"

using namespace std;

int quick_sort(int a[], int l, int r, int x) {
    if (l == r) return a[l];
    int k = a[(l + r) / 2];
    int i = l - 1;
    int j = r + 1;
    while (i < j) {
        while (a[++i] < k);
        while (a[--j] > k);
        if (i < j) {
            swap(a[i], a[j]);
        }
    }
    if (x <= j) {
        return quick_sort(a, l, j, x);
    } else {
        return quick_sort(a, j + 1, r, x);
    }
}

int main() {
    int n, x;
    scanf("%d %d", &n, &x);

    int a[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    int res = quick_sort(a, 0, n - 1, x - 1);

    printf("%d", res);

    return 0;
}